﻿namespace DotNetUtility.GenericDesignPattern.Test
{
    using NUnit.Framework;

    [TestFixture]
    public class ServiceFactoryTest
    {
        [Test]
        public void ServiceInstanceOfPersonA()
        {
            var instanceOfA = (PersonA)ServiceFactory.ServiceInstanceOf<IPerson, PersonA, PersonB>(BusinessLogicPersonASelection);
            Assert.IsInstanceOfType(typeof(PersonA), instanceOfA);
        }

        [Test]
        public void ServiceInstanceOfPersonB()
        {

            var instanceOfB = (PersonB)ServiceFactory.ServiceInstanceOf<IPerson, PersonA, PersonB>(BusinessLogicPersonBSelection);
            Assert.IsInstanceOfType(typeof(PersonB), instanceOfB);
        }

        bool BusinessLogicPersonASelection()
        {
            return true;
        }

        bool BusinessLogicPersonBSelection()
        {
            return default(bool);
        }
    }

    public interface IPerson { string FindPersonName();}

    public class PersonA : IPerson
    {
        public string FindPersonName()
        { return "A"; }
    }
    public class PersonB : IPerson
    {
        public string FindPersonName()
        { return "B"; }
    }
}
